﻿namespace NOAH.CMS.Cache
{
    using NOAH.CMS.Repository;
    using System;
    using System.Collections.Generic;

    public class NewsCacheLayer : BaseCacheLayer
    {
        private NewsArticleRepository _repositoryAPI = null;

        public List<NewsArticle> GetHome(int limit)
        {
            List<NewsArticle> cates = this.GetCacheItem("HotNews") as List<NewsArticle>;
            if (cates == null)
            {
                cates = this.API.GetHotNews(limit);
                this.AddCacheItem("HotNews", cates);
            }
            return cates;
        }


        protected override string[] MasterCacheKeyArray()
        {
            return new string[] { "NewsArticle" };
        }

        protected NewsArticleRepository API
        {
            get
            {
                if (this._repositoryAPI == null)
                {
                    this._repositoryAPI = new NewsArticleRepository();
                }
                return this._repositoryAPI;
            }
        }
    }
}

